package com.delivery.config;

import com.delivery.properties.AliyunOssProperties;
import com.delivery.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class AliOssConfig {

    /**
     * 创建阿里云文件上传工具类
     * 这里的参数是自动注入的
     * @param aliyunOssProperties 自动注入的阿里云文件上传属性类
     */
    @Bean
    public AliOssUtil aliOssUtil(AliyunOssProperties aliyunOssProperties){

        log.info("开始创建阿里云文件上传工具类对象...");
        return new AliOssUtil(aliyunOssProperties.getEndpoint(),aliyunOssProperties.getAccessKeyId(),
                aliyunOssProperties.getAccessKeySecret(),aliyunOssProperties.getBucketName());
    }
}
